package model;

import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Observable;
import java.util.concurrent.LinkedBlockingQueue;

import controller.Msg;
import chatsystemTDa2.*;

/**
 * This is the model: queue of messages to receive
 */
public class MsgRcvd extends Observable {
	
	private LinkedBlockingQueue <Msg> listMsg;
	
	/**
	 * @param listMsg is the queue of received messages created in the controller
	 */
	public MsgRcvd(LinkedBlockingQueue <Msg> listMsg){
		this.listMsg = listMsg;
		
	}
	
	/**
	 * adds a message to the queue
	 * @param m is the message to add to the queue
	 * @param ip is the ip address of the sender of the message
	 */
	public void addMsg(Message m, InetAddress ip){
		Msg msg = new Msg(m, ip);
		this.listMsg.add(msg);
	}
	
	/**
	 * @return is the queue of message received
	 */
	public LinkedBlockingQueue <Msg> getList() {
		return this.listMsg;
	}
}
